import { createBrowserRouter } from 'react-router-dom';
import React from 'react';
import { Outlet } from 'react-router-dom';
import MainLayout from '@/layout/mainLayout/MainLayout';
import AdminController from '@/views/adminController/AdminController';
import UserHome from '@/views/client/user/UserHome';
import EditProfile from '@/views/client/user/EditProfile';
import WorkCenter from '@/views/client/user/WorkCenter';
import UserSetting from '@/views/client/user/UserSetting';
import CultPopMan from '@/views/admin/cultPopMan/CultPopMan';
import ArticleDetail from '@/views/client/articleDetail/ArticleDetail';
import HomeMan from '@/views/admin/homeMan/HomeMan';
import UserMan from '@/views/admin/userMan/UserMan';
import FoodMan from '@/views/admin/suggestMan/FoodMan';
import TouristMan from '@/views/admin/suggestMan/TouristMan';
import TradCraftMan from '@/views/admin/suggestMan/TradCraftMan';
import PublishMan from '@/views/admin/suggestMan/PublishMan';
import AdminDashboard from '@/views/admin/adminDashboard/AdminDashboard';
import UserWorkReview from '@/views/admin/userWorkReview/UserWorkReview';
import Login from '@/views/auth/login/Login.jsx';
import Register from '@/views/auth/register/Register.jsx';
import ForgetPassword from '@/views/auth/forgetPassword/ForgetPassword.jsx';
import AdminLogin from '@/views/auth/admin/adminLogin/AdminLogin.jsx';
import Suggestion from '@/views/client/suggestion/Suggestion.jsx';
import AuthWrapper from '@/components/common/AuthWrapper';
import Community from '../views/client/community/Community.jsx';
import CultPop from '../views/client/cultPop/CultPop.jsx';
import Detail from '../views/client/food/Detail.jsx';
import Food from '../views/client/food/Food.jsx';
import Home from '../views/client/home/Home.jsx';
import LocalFavorites from '../views/client/localFavorites/LocalFavorites.jsx';
import LocZone from '../views/client/locZone/LocZone.jsx';
import Thread from '../views/client/thread/Thread.jsx';
import Tourist from '../views/client/tourist/Tourist.jsx';
import TradCraft from '../views/client/tradCraft/TradCraft.jsx';
import NotFoundPage from '../views/error/NotFoundPage.jsx';
import ServerErrorPage from '../views/error/ServerErrorPage.jsx';

const routes = createBrowserRouter([
    {
        path: '/',
        element: <MainLayout />,
        children: [
            {
                index: true,
                element: (
                    <>
                        <Home />
                        <Outlet />
                    </>
                ),
            },
            {
                path: 'cultPop',
                children: [
                    {
                        index: true,
                        element: <CultPop />,
                    },
                    {
                        path: ':articleId',
                        element: <ArticleDetail />,
                    },
                ],
            },
            { path: 'suggestion', element: <Suggestion /> },
            {
                path: 'community',
                element: (
                    <AuthWrapper validate={false}>
                        <Community />
                    </AuthWrapper>
                ),
            },
        ],
    },
    {
        path: '/auth',
        children: [
            {
                path: 'login',
                element: <Login />,
            },
            {
                path: 'register',
                element: <Register />,
            },
            {
                path: 'forgetpassword',
                element: <ForgetPassword />,
            },
            {
                path: 'admin/login',
                element: <AdminLogin />,
            },
        ],
    },
    {
        path: '/adminController',
        element: <AdminController />,
        children: [
            {
                index: true,
                element: <AdminDashboard />,
            },
            {
                path: 'cultPopMan',
                element: <CultPopMan />,
            },
            {
                path: 'homeMan',
                element: <HomeMan />,
            },
            {
                path: 'userMan',
                element: <UserMan />,
            },
            {
                path: 'userWorkReview',
                element: <UserWorkReview />,
            },
            {
                path: 'recommend',
                children: [
                    {
                        index: true,
                        element: <PublishMan />,
                    },
                    {
                        path: 'foodMan',
                        element: <FoodMan />,
                    },
                    {
                        path: 'touristMan',
                        element: <TouristMan />,
                    },
                    {
                        path: 'tradCraftMan',
                        element: <TradCraftMan />,
                    },
                ],
            },
        ],
    },
    {
        path: '/user',
        element: <UserHome />,
        children: [
            {
                index: true,
                element: <WorkCenter />,
            },
            {
                path: 'editProfile',
                element: <EditProfile />,
            },
            {
                path: 'userSetting',
                element: <UserSetting />,
            },
        ],
    },
    {
        path: '/client/community',
        element: <Community />,
    },
    {
        path: '/client/cultpop',
        element: <CultPop />,
    },
    {
        path: '/client/food/detail',
        element: <Detail />,
    },
    {
        path: '/client/food',
        element: <Food />,
    },
    {
        path: '/client/home',
        element: <Home />,
    },
    {
        path: '/client/localfavorites',
        element: <LocalFavorites />,
    },
    {
        path: '/client/loczone',
        element: <LocZone />,
    },
    {
        path: '/client/thread',
        element: <Thread />,
    },
    {
        path: '/client/tourist/detail',
        element: <Detail />,
    },
    {
        path: '/client/tourist',
        element: <Tourist />,
    },
    {
        path: '/client/tradcraft/detail',
        element: <Detail />,
    },
    {
        path: '/client/tradcraft',
        element: <TradCraft />,
    },
    {
        path: '/error/notFoundPage',
        element: <NotFoundPage />,
    },
    {
        path: '/error/serverErrorPage',
        element: <ServerErrorPage />,
    },
]);

export default routes;
